package engine

import (
	"log"
)

type SimpleEngine struct{}

func (e SimpleEngine) Run(seeds ...Request) { // ...slice内容展开取进来
	var requests []Request // 维护一个队列放入每一个Request
	for _, r := range seeds {
		requests = append(requests, r)
	}
	for len(requests) > 0 {
		r := requests[0]
		requests = requests[1:]
		parseResult, err := Worker(r)
		if err != nil {
			continue
		}
		requests = append(requests, parseResult.Requests...) // 将解析结果中的requests添加到维护slice中...slice展开逐一append

		for _, item := range parseResult.Items {
			log.Printf("Got item %v", item)
		}
	}
}
